#ifndef DEVICEMANAGER_H
#define DEVICEMANAGER_H

#include <QMainWindow>
#include <QStandardItemModel>
#include <QPushButton>
#include <QSqlError>
#include <QTreeView>
#include <QSortFilterProxyModel>
#include "deviceInfo.h"
#include "devicedatatest.h"
#include "buttondelegate.h"
#include "../MainProject/loggermanager.h"
#include "../MainProject/common.h"
#include "tableviewheader.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class DeviceManager;
}
QT_END_NAMESPACE

class DeviceManager : public QMainWindow
{
    Q_OBJECT

public:
    DeviceManager(QWidget *parent = nullptr);
    ~DeviceManager();
    void readDeviceManager();
    void connects();
    QJsonObject getViewActualDevicesIdbyLine();
    QJsonArray getViewActualDevicesIdbySelectBox();
signals:
    void sinDeviceEdit(int);
public slots:
    void onCreateDeviceInfo();
    void onModifyDeviceInfo();
    void onDeleteDeviceInfo();
    void onEditClicked(const QModelIndex &index);
    void onDeleteClicked(const QModelIndex &index);
    void onShowDeviceList();
    void onSetBtns();
    void ReceiveLogininformation(QString &userName,QString &role);
    void onImportDevices();
    void onShowView(const QString querySql="SELECT * FROM devices");
    void onSortButtonClicked(int logicalIndex);
    void onGroupButtonClicked(int logicalIndex);
private:
    Ui::DeviceManager *ui;
    QStandardItemModel* model;
    DeviceInfo *m_pDeviceInfo;
    SQLiteDatabase *db;
    Common common;
    bool showBtnsflag;
    QString logText;
    QSortFilterProxyModel *proxyModel;
    TableViewHeader *header;
    QStringList tableNames;
    QStringList headerNames;
};
#endif // DEVICEMANAGER_H
